package cn.itcast.service.user.impl;

import cn.itcast.dao.user.IUserDAO;
import cn.itcast.domain.user.UserModel;
import cn.itcast.service.user.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements IUserService{
    @Autowired
    private IUserDAO userDAO;


    @Override
    public UserModel findByUsername(String username) {
        return userDAO.findByUsername(username);
    }

    @Override
    public UserModel findByPhone(String phone) {
        return userDAO.findByPhone(phone);
    }

    @Override
    public boolean addUser(UserModel user) {
         UserModel u=userDAO.save(user);
         return u!=null;
    }

    @Override
    public UserModel login(String username, String pwd) {
        return userDAO.login(username,pwd);
    }
}
